package com.linck.im.client.context;

import com.linck.im.client.ImClient;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * @author: linck
 * @create: 2021-08-07
 */
public class StageContext {

    private static Stage stage;

    public static void setStage(Stage stage) {
        StageContext.stage = stage;
    }

    public static void changeChatView() {
        Platform.runLater(() -> {
            FXMLLoader fxmlLoader = new FXMLLoader(ImClient.class.getResource("controller/chat-view.fxml"));
            Scene scene = null;
            try {
                scene = new Scene(fxmlLoader.load(), stage.getWidth(), stage.getHeight());
            } catch (IOException e) {
                e.printStackTrace();
            }
            stage.setTitle("IM Client");
            stage.setScene(scene);
        });
    }
}
